<template>
  <div class="Policy">
    <!--banner-->
    <div class="banner">
      <div class="wh-1200 auto banner-txt pt-50">
        <h1>通知公告</h1>
        <span>Notice and Announcement</span>
      </div>
    </div>

    <!--政策规范-->
    <div class="wh-1200 auto main mt-40">
      <!-- 标题模块 -->
      <div class="main-title mt-40">
        <img src="@/assets/images/message.png" alt />
        <span>通知公告</span>
      </div>

      <!-- 搜索模块 -->
      <div class="main-search">
        <a-form-model :label-col="{ span: 2 }">
          <a-form-model-item label="关键字">
            <a-input v-model="searchfrom.keyword" placeholder="请输入通知公告标题" />
            <a-button class="ant-btn1" @click="Search">搜索</a-button>
            <!-- <span @click="show=!show" v-show="!show" class="show-btn">
              高级搜索
              <a-icon type="caret-right" />
            </span>
            <span @click="show=!show" v-show="show" class="show-btn" style="color: #188af1;">
              高级搜索
              <a-icon type="caret-down" />
            </span> -->
          </a-form-model-item>
        </a-form-model>

        <div v-show="show">
          <div>
            <a-form-model class="mt-10" :label-col="{ span: 2 }" :wrapper-col="{ span: 14 }">
              <a-form-model-item label="行业类别：">
                <a-select placeholder="请选择" style="width: 120px" class="mr-32">
                  <a-select-option v-for="(item, index) in selectType" :key="index" :value="item.name">{{ item.name
                    }}</a-select-option>
                </a-select>
                <a-select placeholder="请选择" style="width: 120px" class="mr-32">
                  <a-select-option v-for="(item, index) in selectType" :key="index" :value="item.name">{{ item.name
                    }}</a-select-option>
                </a-select>
              </a-form-model-item>

              <a-form-model-item label="公告类型：">
                <a-select placeholder="请选择" style="width: 120px" class="mr-32">
                  <a-select-option v-for="(item, index) in selectType1" :key="index" :value="item.name">{{ item.name
                    }}</a-select-option>
                </a-select>
              </a-form-model-item>
            </a-form-model>
          </div>
        </div>
      </div>

      <div class="main-searchResult clearfix">
        <div class="f-left search-left">
          <span v-if="newkeyword != ''">

            搜索："
            <span class="search-text1">{{ newkeyword }}</span>
            "
          </span>
          共
          <span class="search-text2">{{ total }}</span> 条数据
        </div>
        <div class="f-right search-right clearfix">
          <!-- <a-button>
            <div class="f-left search-right-icon">
              <div>
                <a-icon type="caret-up" />
              </div>
              <div>
                <a-icon type="caret-down" class="down" />
              </div>
            </div>
            <div class="f-left remainingTime">发布时间</div>
          </a-button> -->
          <a-button @click="SwitchisOrderDesc">
            <div class="f-left search-right-icon">
              <div>
                <a-icon :class="!searchfrom.isOrderDesc ? '' : 'down'" type="caret-up" />
              </div>
              <div>
                <a-icon :class="searchfrom.isOrderDesc ? '' : 'down'" type="caret-down" />
              </div>
            </div>
            <div class="f-left remainingTime">发布时间</div>
          </a-button>
        </div>
      </div>

      <!--列表模块-->
      <div class="list-box">
        <ul>
          <li class="pb-16 pt-8 pr-8" v-for="(item, index) in NoticeData" :key="index" @click="toDetail(item.noticeId)">
            <div class="list-dot"></div>
            <div class="pl-32 pt-24">
              <h1 class="list-title pb-8">
                {{ item.noticeTitle }}
              </h1>
              <div class="desc rows-ellipsis">
                {{ item.createBy }}
              </div>
              <div class="other"><span class="pr-32">来源：{{ item.noticeType == 1 ? '通知' : '公告' }}</span><span>发布时间：{{
                item.createTime }}</span>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <NoData v-if="NoticeData.length <= 0" :Keywords="newkeyword"></NoData>
      <div v-if="NoticeData.length > 0" class=" mt-40 tc mb-100">
        <a-pagination :show-total="total => `共有 ${total} 条数据`" show-quick-jumper :default-current="searchfrom.current"
          @showSizeChange="showSizeChanger" show-size-changer :defaultPageSize="10"
          :pageSizeOptions="['10', '20', '30', '40']" :total="total" @change="onChange" />
      </div>
    </div>
  </div>
</template>
<script>
import NoData from "@/components/Nodata";

import { getsysActivityList } from "@/apis/SysActivity";
import { getNoticeList } from "@/apis/system/index"
export default {
  data () {
    return {
      show: false,
      selectType: [
        { name: "电子", key: 1 },
        { name: "织纺", key: 2 },
        { name: "化工", key: 3 },
        { name: "建材", key: 4 },
        { name: "机械", key: 5 },
        { name: "轻工", key: 6 },
        { name: "食品", key: 7 },
        { name: "冶金", key: 8 },
        { name: "制药", key: 9 },
        { name: "通用服务", key: 10 },
        { name: "抗议物资", key: 11 },
      ],
      selectType1: [
        { name: "供需活动", key: 1 },
        { name: "龙华区", key: 2 },
      ],
      newkeyword: "",
      searchfrom: {
        current: 1,
        size: 10,
        keyword: "",
        isOrderDesc: true
      },
      total: 0,
      NoticeData: []
    };
  },
  created () {
    this.getsysActivityList();
  },
  components: {
    NoData,
  },
  methods: {
    Search () {
      if (this.searchfrom.keyword != "") {
        this.newkeyword = this.searchfrom.keyword;
      } else {
        this.newkeyword = "";
      }
      this.searchfrom.current = 1;
      this.getsysActivityList();
    },
    toDetail (id) {
      this.$router.push("/NoticeDetails?id=" + id);
    },
    toHomePage () {
      this.$router.push("/homePage");
    },
    //排序
    SwitchisOrderDesc () {
      this.searchfrom.isOrderDesc = !this.searchfrom.isOrderDesc;
      this.getsysActivityList();
    },
    // 当前页
    onChange (page, pageSize) {
      this.searchfrom.current = page;
      this.getsysActivityList();
    },
    //每页显示条数
    showSizeChanger (current, size) {
      this.searchfrom.size = size;
      this.searchfrom.current = current;
      this.getsysActivityList();
    },
    getsysActivityList () {
      console.log("this.searchfrom", this.searchfrom)
      const params = {
        pageSize: this.searchfrom.size,
        pageNum: this.searchfrom.current,
        isOrderDesc: this.searchfrom.isOrderDesc,
        noticeTitle: this.searchfrom.keyword

      }
      getNoticeList(params)
        .then((res) => {
          if (res.code == 200) {
            this.NoticeData = res.rows;
            this.total = res.total;
          }
        })
        .catch((error) => { });
    },
  },
};
</script>
<style lang="less" scoped>
.Policy {
  .banner {
    background: url("../../../assets/images/newsBanner.png") no-repeat center;
    height: 200px;

    h1 {
      height: 60px;
      line-height: 60px;
      color: rgb(7, 41, 71);
      font-size: @font36;
      font-weight: lighter;
    }

    span {
      font-size: @font36;
      color: rgba(7, 41, 71, 58%);
    }
  }

  .main-title {
    img {
      width: 40px;
      height: 40px;
      margin-right: 16px;
      vertical-align: middle;
      margin-top: -10px;
    }

    span {
      font-family: Microsoft YaHei;
      font-size: @font26;
      line-height: @font26;
      font-weight: 700;
      color: @text-color-303;
    }
  }

  .main-search {
    margin-top: 24px;
    margin-bottom: 24px;

    ::v-deep .ant-col-2 {
      width: auto !important;
    }

    &:nth-child(1) {
      font-family: Microsoft YaHei;
      font-size: @font14;
      font-weight: normal;
      line-height: 19px;
      color: @text-color-606;
      margin-right: 8px;
    }

    .ant-input {
      width: 500px;
      height: 40px;
    }

    .ant-btn1 {
      margin-left: 12px;
      margin-right: 40px;
      width: 100px;
      height: 40px;
      background-color: #2a51bc;
      box-shadow: 0px 10px 20px 0px rgba(7, 41, 71, 0.16);
      border-radius: 4px;
      color: #fff;
    }

    .show-btn {
      cursor: pointer;

      &:hover {
        color: #188af1;
      }
    }

    &:nth-child(4) {
      font-family: Microsoft YaHei;
      font-size: @font16;
      font-weight: normal;
      line-height: 21px;
      color: @text-color-606;
    }
  }

  .main-searchResult {
    height: 70px;
    line-height: 70px;
    background-color: #fff;
    box-shadow: 0px 3px 10px 0px rgba(24, 138, 241, 0.16);
    border-radius: 4px;
    margin-bottom: 8px;

    .search-left {
      margin-left: 26px;
      font-size: @font16;

      .search-text1 {
        color: #2a51bc;
      }

      .search-text2 {
        color: #e9284f;
        font-weight: 700;
      }
    }

    .search-right {
      margin-right: 24px;

      .ant-btn {
        margin-left: 16px;
        width: 120px;
        height: 40px;
        line-height: 1;
        border: solid 1px #188af1;
        color: #188af1;
        font-size: @font16;

        &:hover {
          background-color: #188af1;
          color: #fff;
        }
      }

      .down {
        opacity: 0.5;
      }

      .remainingTime {
        padding-left: 5px;
        line-height: 32px;
      }

      .search-right-icon {
        div {
          width: 14px;
          height: 9px;
        }

        padding-top: 3px;
      }
    }
  }

  .list-box {
    ul li {
      position: relative;
      border-bottom: 1px solid #e4e7ed;

      &:hover {
        box-shadow: 0px 6px 30px 0px rgba(24, 138, 241, 0.16);
        border-bottom: 0 none;
        cursor: pointer;
      }

      .list-dot {
        width: 8px;
        height: 16px;
        background: #188af1;
        position: absolute;
        top: 36px;
        left: 8px;
      }

      div {
        .list-title {
          font-size: @font18;
          font-weight: bold;

          &:hover {
            color: @color-188;
          }
        }

        .desc {
          color: @text-color-606;
          line-height: 26px;
        }

        .rows-ellipsis {
          -webkit-line-clamp: 2; // 用来限制在一个块元素显示的文本的行数
          display: -webkit-box; // 将对象作为弹性伸缩盒模型显示
          -webkit-box-orient: vertical; //设置或检查伸缩盒对象的子元素的排列方式
          text-overflow: ellipsis; // 在多行文本的情况下，用...隐藏超出范围的文本
          word-break: break-all;
          overflow: hidden;
        }

        .other {
          font-size: @font12;
          color: @text-color-909;

          span {
            display: inline-block;
          }
        }
      }
    }
  }
}
</style>